package com.zhuiYun.project.api.homepagefunction.popularrecommendation.controller;
import com.zhuiYun.project.api.commoditydetail.entity.Commodity;
import com.zhuiYun.project.api.homepagefunction.popularrecommendation.service.PopularRecommendationService;
import com.zhuiYun.project.common.controller.BaseController;
import com.zhuiYun.project.common.errorCode.CommonException;
import com.zhuiYun.project.common.response.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
 * @ClassName PopularRecommendationController
 * @Description 人气推荐管理
 * @Author lzk
 * @Date 2023/4/3 15:02
 **/
@RestController
@RequestMapping("/popularRecommendation")
@Api(tags = "人气推荐管理")
@Slf4j
@CrossOrigin
public class PopularRecommendationController extends BaseController {
    @Autowired
    PopularRecommendationService popularRecommendationService;
    /**
     * @Author lzk
     * @Description 人气推荐根据商品售卖量进行排序查询
     * @date 2023/4/4 8:36
     * Return CommonResult
     */
    @GetMapping("/queryBasedOnSalesVolume")
    @ApiOperation(value = "人气推荐根据商品购买量进行排序查询")
    public CommonResult queryBasedOnSalesVolume() throws CommonException {
        List<Commodity> list = popularRecommendationService.queryBasedOnSalesVolume();
        log.info("人气推荐根据商品售卖量进行排序查询"+list);
        return CommonResult.ok(list);
    }
}
